Skip to content

feat: Add LiveQuery query operation#10470

Open
Corvus400 wants to merge 2 commits into
parse-community:alphafrom
Corvus400:todayama/live-query-query-9086
Open

feat: Add LiveQuery query operation#10470
Corvus400 wants to merge 2 commits into
parse-community:alphafrom
Corvus400:todayama/live-query-query-9086

Conversation

@Corvus400
Copy link
Copy Markdown

@Corvus400 Corvus400 commented May 20, 2026

Issue

Closes #9086 and resumes #9864.

Approach

This adds one socket request for saved live query rows.

The server uses saved auth and selected fields.

Missing client or query data returns a clear error.

Tasks

Schema, server path, result messages, and tests are done.

Checks

Specs, lint, and build passed.

/claim #9086

Summary by CodeRabbit

  • New Features

    • Added support for executing queries on live subscriptions with configurable field selection.
    • Implemented automatic result filtering based on subscription parameters.
    • Enhanced error handling for malformed query requests and missing subscriptions.
  • Tests

    • Added comprehensive test coverage for query operations and result formatting.
    • Added tests validating field selection and error scenarios.

@parse-github-assistant
Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title feat: add LiveQuery query operation feat: Add LiveQuery query operation May 20, 2026
@parse-github-assistant
Copy link
Copy Markdown

parse-github-assistant Bot commented May 20, 2026

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 691b6da0-986f-479f-852f-34d7f248eb68

📥 Commits

Reviewing files that changed from the base of the PR and between b72daab and 1bd62e9.

📒 Files selected for processing (5)
  • spec/Client.spec.js
  • spec/ParseLiveQueryQuery.spec.js
  • src/LiveQuery/Client.js
  • src/LiveQuery/ParseLiveQueryServer.ts
  • src/LiveQuery/RequestSchema.js
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/LiveQuery/Client.js
  • src/LiveQuery/RequestSchema.js
  • spec/Client.spec.js
  • src/LiveQuery/ParseLiveQueryServer.ts
  • spec/ParseLiveQueryQuery.spec.js

📝 Walkthrough

Walkthrough

Adds a websocket query operation: request schema, server-side _handleQuery to run stored subscriptions (where/keys/auth), client-side pushResult to emit op: 'result', and unit tests covering success and error scenarios.

Changes

Live Query Query Operation

Layer / File(s) Summary
Query Operation Schema Definition
src/LiveQuery/RequestSchema.js
Request schema enum and operation definition updated to support op: 'query' with numeric requestId.
Client Result Publishing
src/LiveQuery/Client.js, spec/Client.spec.js
Client.pushResult/_pushQueryResult serializes results (applying per-subscription field filtering via _toJSONWithFields), sends op: 'result' messages, and handles missing results as empty arrays. Tests verify payload structure, field selection, and empty results.
Server Query Execution and Dispatch
src/LiveQuery/ParseLiveQueryServer.ts, spec/ParseLiveQueryQuery.spec.js
Server dispatch routes query to _handleQuery, which validates client/subscription, builds and runs a Parse.Query with stored class/where/keys and appropriate auth, then calls client.pushResult or Client.pushError; specs cover success, missing clientId, missing subscription, field filtering, and where-clause matching.

Sequence Diagram

sequenceDiagram
  participant Client as WebSocket Client
  participant Server as ParseLiveQueryServer
  participant DB as Parse.Query
  participant Response as Client.pushResult

  Client->>Server: {"op":"query","requestId":123}
  
  Server->>Server: Validate clientId exists
  Server->>Server: Lookup subscription by requestId
  
  Server->>DB: new Parse.Query(className)
  DB->>DB: Apply where clause
  DB->>DB: Apply field selection (keys)
  
  Server->>DB: find(sessionToken or useMasterKey)
  DB-->>Server: results array
  
  Server->>Response: pushResult(subscriptionId, results)
  Response->>Response: Map results via _toJSONWithFields
  Response-->>Client: {"op":"result","requestId":123,"results":[...]}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title begins with the required 'feat:' prefix and clearly describes the main change - adding a LiveQuery query operation.
Description check ✅ Passed The description covers the issue (closes #9086, resumes #9864), approach (socket request for saved queries with auth/fields), and tasks (schema, server path, results, tests). However, it lacks explicit checkboxes from the template.
Linked Issues check ✅ Passed The PR fully implements the primary coding objective from #9086: allowing Parse queries through LiveQueryClient via WebSocket. The implementation adds a 'query' operation with proper authentication, field selection, and error handling.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the LiveQuery query operation objective. No unrelated modifications to unrelated features or out-of-scope refactoring detected.
Security Check ✅ Passed Reuses subscription authorization via sessionToken and Parse.Query enforcement. Schema validates requests to prevent injection. Queries limited to pre-authorized subscriptions.
Engage In Review Feedback ✅ Passed PR #10470 is an open pull request awaiting review with no review feedback comments present. The custom check requiring engagement with review feedback is not applicable when no feedback exists.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.22.0)

OpenGrep fatal error (exit code 2): [00.11][ERROR]: Error: exception Unix_error: No such file or directory stat spec/Client.spec.js
Raised by primitive operation at UTmp.replace_named_pipe_by_regular_file_if_needed in file "libs/commons/UTmp.ml", line 145, characters 8-27
Called from Scan_CLI.replace_target_roots_by_regular_files_where_needed.(fun) in file "src/osemgrep/cli_scan/Scan_CLI.ml", lines 1086-1087, characters 19-65
Called from List_.fast_map in file "libs/commons/List_.ml", line 81, characters 17-20
Called from Scan_CLI


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 20, 2026
@Corvus400
Copy link
Copy Markdown
Author

This is ready for review.

This PR resumes #9864.

It keeps the server change focused.

The JS SDK side appears released in parse-community/Parse-SDK-JS#2114.

Local checks passed.

See the PR body for the commands.

@Corvus400 Corvus400 force-pushed the todayama/live-query-query-9086 branch from b72daab to 1bd62e9 Compare May 31, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to run queries through LiveQueryClient

1 participant